package com.aizhixin.lab.resource.service;

import com.aizhixin.lab.resource.domain.CreateFileDirDomain;
import com.aizhixin.lab.resource.entity.Dir;
import com.aizhixin.lab.resource.repository.DirFileRepository;
import com.aizhixin.lab.resource.repository.DirRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Slf4j
@Service
@Transactional
public class DirService {
    @Autowired
    private DirRepository dirRepository;
    @Autowired
    private DirFileRepository dirFileRepository;

    /**
     * 新建文件夹
     * @param domain
     * @param createBy
     */
    public void createFolder(CreateFileDirDomain domain, Long createBy) {
        Dir dir = new Dir();
        dir.setProfId(domain.getProfId());
        dir.setDirName(domain.getFolderName());
        dir.setCreatedBy(createBy);
        dir.setCreatedDate(new Date());
        dir.setDeleteFlag(0);
        dirRepository.save(dir);
    }



}
